home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / bash_completion.d / postfix < prev    next >
Encoding:
Text File  |  2010-11-16  |  5.0 KB  |  232 lines

  1. # bash completion for postfix
  2.  
  3. have postfix && {
  4. # postfix(1)
  5. #
  6. _postfix()
  7. {
  8.     local cur prev
  9.  
  10.     COMPREPLY=()
  11.     _get_comp_words_by_ref cur prev
  12.  
  13.     case $prev in
  14.         -c)
  15.             _filedir -d
  16.             return 0
  17.             ;;
  18.         -D)
  19.             COMPREPLY=( $( compgen -W 'start' -- "$cur" ) )
  20.             return 0
  21.             ;;
  22.     esac
  23.  
  24.     if [[ $cur == -* ]]; then
  25.         COMPREPLY=( $( compgen -W '-c -D -v' -- "$cur" ) )
  26.         return 0
  27.     fi
  28.  
  29.     COMPREPLY=( $( compgen -W 'check start stop abort flush reload status \
  30.         set-permissions upgrade-configuration' -- "$cur" ) )
  31. }
  32. complete -F _postfix -o filenames postfix
  33.  
  34. # postalias(1) and postmap(1)
  35. #
  36. _postmap()
  37. {
  38.     local cur prev len idx
  39.  
  40.     COMPREPLY=()
  41.     _get_comp_words_by_ref cur prev
  42.  
  43.     case $prev in
  44.         -c)
  45.             _filedir -d
  46.             return 0
  47.             ;;
  48.         -[dq])
  49.             return 0
  50.             ;;
  51.     esac
  52.  
  53.     if [[ $cur == -* ]]; then
  54.         COMPREPLY=( $( compgen -W '-N -f -i -n -o -p -r -v -w -c -d -q'\
  55.             -- "$cur" ) )
  56.         return 0
  57.     fi
  58.  
  59.     if [[ "$cur" == *:* ]]; then
  60.             COMPREPLY=( $( compgen -f -- "${cur#*:}" ) )
  61.     else
  62.         len=${#cur}
  63.         idx=0
  64.         for pval in $( /usr/sbin/postconf -m ); do
  65.             if [[ "$cur" == "${pval:0:$len}" ]]; then
  66.                 COMPREPLY[$idx]="$pval:"
  67.                 idx=$(($idx+1))
  68.             fi
  69.         done
  70.         if [[ $idx -eq 0 ]]; then
  71.             COMPREPLY=( $( compgen -f -- "$cur" ) )
  72.         fi
  73.     fi
  74.     return 0
  75. }
  76. complete -F _postmap -o filenames postmap postalias
  77.  
  78. # postcat(1)
  79. #
  80. _postcat()
  81. {
  82.     local cur prev pval len idx qfile
  83.  
  84.     COMPREPLY=()
  85.     _get_comp_words_by_ref cur prev
  86.  
  87.     case $prev in
  88.         -c)
  89.             _filedir -d
  90.             return 0
  91.             ;;
  92.     esac
  93.  
  94.     if [[ $cur == -* ]]; then
  95.         COMPREPLY=( $( compgen -W '-c -q -v' -- "$cur" ) )
  96.         return 0
  97.     fi
  98.  
  99.     qfile=0
  100.     for idx in "${COMP_WORDS[@]}"; do
  101.         [[ "$idx" = -q ]] && qfile=1 && break
  102.     done
  103.     if [[ $qfile == 1 ]]; then
  104.         len=${#cur}
  105.         idx=0
  106.         for pval in $( mailq 2>/dev/null | \
  107.             sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* !].*$//' ); do
  108.             if [[ "$cur" == "${pval:0:$len}" ]]; then
  109.                 COMPREPLY[$idx]=$pval
  110.                 idx=$(($idx+1))
  111.             fi
  112.         done
  113.         return 0
  114.     else
  115.         _filedir
  116.         return 0
  117.     fi
  118. }
  119. complete -F _postcat -o filenames postcat
  120.  
  121. # postconf(1)
  122. #
  123. _postconf()
  124. {
  125.     local cur prev pval len idx eqext
  126.  
  127.     COMPREPLY=()
  128.     _get_comp_words_by_ref cur prev
  129.  
  130.     case $prev in
  131.         -b|-t)
  132.             _filedir
  133.             return 0
  134.             ;;
  135.         -c)
  136.             _filedir -d
  137.             return 0
  138.             ;;
  139.         -e)
  140.             cur=${cur#[\"\']}
  141.             eqext='='
  142.             ;;
  143.     esac
  144.  
  145.     if [[ $cur == -* ]]; then
  146.         COMPREPLY=( $( compgen -W '-A -a -b -c -d -e -h -m -l -n -t -v'\
  147.             -- "$cur" ) )
  148.         return 0
  149.     fi
  150.  
  151.     len=${#cur}
  152.     idx=0
  153.     for pval in $( /usr/sbin/postconf 2>/dev/null | cut -d ' ' -f 1 ); do
  154.         if [[ "$cur" == "${pval:0:$len}" ]]; then
  155.             COMPREPLY[$idx]="$pval$eqext"
  156.             idx=$(($idx+1))
  157.         fi
  158.     done
  159.     return 0
  160. }
  161. complete -F _postconf -o filenames postconf
  162.  
  163. # postsuper(1)
  164. #
  165. _postsuper()
  166. {
  167.     local cur prev pval len idx
  168.  
  169.     COMPREPLY=()
  170.     _get_comp_words_by_ref cur prev
  171.  
  172.     case $prev in
  173.         -c)
  174.             _filedir -d
  175.             return 0
  176.             ;;
  177.         -[dr])
  178.             len=${#cur}
  179.             idx=0
  180.             for pval in ALL $( mailq 2>/dev/null | \
  181.                 sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* !].*$//' ); do
  182.                 if [[ "$cur" == "${pval:0:$len}" ]]; then
  183.                     COMPREPLY[$idx]=$pval
  184.                     idx=$(($idx+1))
  185.                 fi
  186.             done
  187.             return 0
  188.             ;;
  189.         -h)
  190.             len=${#cur}
  191.             idx=0
  192.             for pval in ALL $( mailq 2>/dev/null | \
  193.                 sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* ].*$//; /!$/d' ); do
  194.                 if [[ "$cur" == "${pval:0:$len}" ]]; then
  195.                     COMPREPLY[$idx]=$pval
  196.                     idx=$(($idx+1))
  197.                 fi
  198.             done
  199.             return 0
  200.             ;;
  201.         -H)
  202.             len=${#cur}
  203.             idx=0
  204.             for pval in ALL $( mailq 2>/dev/null | \
  205.                 sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; /^[0-9A-Z]*[* ]/d; s/!.*$//' ); do
  206.                 if [[ "$cur" == "${pval:0:$len}" ]]; then
  207.                     COMPREPLY[$idx]=$pval
  208.                     idx=$(($idx+1))
  209.                 fi
  210.             done
  211.             return 0
  212.             ;;
  213.     esac
  214.  
  215.     if [[ $cur == -* ]]; then
  216.         COMPREPLY=( $( compgen -W '-c -d -h -H -p -r -s -v' -- "$cur" ) )
  217.         return 0
  218.     fi
  219.  
  220.     COMPREPLY=( $( compgen -W 'hold incoming active deferred' -- "$cur" ) )
  221. }
  222. complete -F _postsuper -o filenames postsuper
  223. }
  224.  
  225. # Local variables:
  226. # mode: shell-script
  227. # sh-basic-offset: 4
  228. # sh-indent-comment: t
  229. # indent-tabs-mode: nil
  230. # End:
  231. # ex: ts=4 sw=4 et filetype=sh
  232.